﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using vuonthieunhi.Models;

namespace vuonthieunhi.Areas.Administration.Models
{
    public class StockDao:BaseDao
    {
        public Stock GetByID(int partnerID)
        {
            return dbContext.Stocks.Where(q => q.PartnerID.Equals(partnerID)).FirstOrDefault();
        }

        public void Update(Stock objUI)
        {
            Stock objDb = GetByID(objUI.PartnerID);
            if (objDb != null)
            {
                objDb.Quality = objUI.Quality;
                dbContext.SubmitChanges();
            }
            else
            {
                dbContext.Stocks.InsertOnSubmit(objUI);
                dbContext.SubmitChanges();
            }
        }
    }
}